package com.tgy.leetcode;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @Author: tgy
 * @Date: 1/14/21 9:46 AM
 */
public class _1018_可被5整除的二进制前缀 {

    public List<Boolean> prefixesDivBy5(int[] A) {

        List<Boolean> result = new ArrayList<>();

        if (A == null || A.length == 0) {

            return result;
        }

        int sum = 0;


        for (int i = 0; i < A.length; i++) {

            sum = ((sum << 1) | A[i]) % 5;
            System.out.println(sum);
            result.add(sum == 0);
        }


        return result;
    }

    public static void main(String[] args) {

        _1018_可被5整除的二进制前缀 prefixesDivBy5 = new _1018_可被5整除的二进制前缀();

        List<Boolean> result = prefixesDivBy5.prefixesDivBy5(new int[]{0, 1, 1, 1, 1, 1});

        System.out.println(result);


    }
}
